﻿var houseConfigApp = angular.module('houseConfigApp', []);


 houseConfigApp.controller('ItemListCtrl', ['$scope', '$http', function ($scope, $http) {

//数据-->视图；
     $http({method:'get',url:'data/houseConfig.json'})
        .success(function (data) {
          console.log(data);
          $scope.items = data;

          //arr1  1~500的数组
          //arr0  0~32的数组
          var arr1 = [], arr0 =[];
          for(var i=1;i<=500;i++){
            arr1.push(i);
          }
          for(var j=0;j<=32;j++){
            arr0.push(j);
          }

          $scope.range1 = arr1;
          $scope.range0 = arr0;

        
            // 
            var selects = document.getElementsByTagName("select");
            console.log(selects);
            for(var k=0; k<selects.length; k++){
              selects[k].setAttribute("id",k);
              //console.log(selects[]);
              //??var selIndex = $scope.items[i].deviceId;
              // var sel = document.getElementsById(i);
              // console.log(sel);
              // var sel_opt = document.getElementsById(i).child("[value='"+selIndex+"']");
              // console.log(sel_opt);
            }
            
        })
        .error(function (errorMsg) {
          console.log(errorMsg);
        });

//视图-->数据
        // $scope.$watch('name',function(){
        //   console.log($scope.name);
        // });
}]);

 jQuery(document).ready(function () {
      //当页面加载完成后，每个粮仓（每一行）显示当前配置。每个select 的对应的 option 添加selected="selected" 属性
       $("select").each(  function(){
            $(this).attr("id", ++i);
         });
  });   
